#include "transpiler.h"

#include "ast.h"

using namespace std;

Transpiler::Transpiler() :
    m_code(new AstCodeBlock()),
    m_places(),
    m_transitions(),
    m_connections()
{

}

Transpiler::~Transpiler()
{

}

string Transpiler::transpile(AstCodeBlock *code)
{
    string ret;

    sortStatements(code);
    checkSemanticErrors();
    ret = generateXml();

    return ret;
}

void Transpiler::sortStatements(AstCodeBlock *code)
{
    list<AstStatement* > stmts = code->statements();

    int lastColsetD = 0;
    int lastValD = 0;
    int lastVarD = 0;

    for (list<AstStatement* >::const_iterator it; it != stmts.end(); ++it)
    {
        AstStatement* stmt = *it;
        switch (stmt->nodeType())
        {
        case ColsetDeclaration:
            break;
        case ValueDeclaration:
            break;
        case VariableDeclaration:
            break;
        case Connection:
            break;
        default:
            continue;
        }
    }
}

bool Transpiler::checkSemanticErrors() const
{
    bool ret = true;

    return ret;
}

string Transpiler::generateXml() const
{
    string ret;

    return ret;
}
